package org.hegang.design.first.prototypepattern;



/**
 * @ClassName PrototypePatternMain
 * @Describe: 原型模式
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 23:35 2019/7/3
 * @Modified_By: TODO
 * @Version: V1.0
 */
public class PrototypePatternMain {
    public static void main(String[] args) {
        //加载缓存，可从数据库或其他途径中获取
        ShapeCache.loadCache();

        //从缓存中克隆获取创建代价大的对象
        Rectangle rectangle = (Rectangle) ShapeCache.getAbstractShape("1");
        System.out.println("Shape Type: " + rectangle.getType());

        Circle circle = (Circle) ShapeCache.getAbstractShape("2");
        System.out.println("Shape Type: " + circle.getType());

        Square square = (Square) ShapeCache.getAbstractShape("3");
        System.out.println("Shape Type: " + square.getType());
    }
}
